package com.spzx.order.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.order.api.RemoteOrderInfoService;
import com.spzx.order.api.domain.OrderInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

public class RemoteOrderInfoServiceFallbackFactory implements FallbackFactory<RemoteOrderInfoService> {
 private static final Logger log= LoggerFactory.getLogger(RemoteOrderInfoServiceFallbackFactory.class);
    @Override
    public RemoteOrderInfoService create(Throwable cause) {
        log.error("订单服务调用失败:{}", cause.getMessage());
        return new RemoteOrderInfoService() {
            @Override
            public R<OrderInfo> getByOrderNo(String orderNo, String source) {
                return R.fail("根据订单号获取订单信息失败:" + cause.getMessage());
            }
        };
    }
}
